using System;

namespace Karma.Framework.Core.Modules.Reports.Definition.Expression
{
    internal abstract class UnaryExpression : ExpressionBase
    {
        protected string _operand;

        protected IExpression _exp;

        public UnaryExpression(Criteria criteria)
            : base(criteria)
        {
            if (String.IsNullOrEmpty(criteria.Expression))
            {
                throw new ArgumentException(
                    string.Format("{0}. The value of [Expression] must not be null.", GetType().Name));
            }
            if (criteria.OperandValues == null)
            {
                throw new ArgumentException(
                    string.Format("{0}. The operand value must not be null.",
                                  GetType().Name));
            }
            if (criteria.OperandValues.Count != 1)
            {
                throw new ArgumentException(
                    string.Format("{0}. The operand value must not be null.",
                                  GetType().Name));
            }

            _operand = criteria.Expression;
        }
    }
}